/*
CCP 1.8
Assume you have a method isSubstring which checks if one word is
 a substring of another. Given two strings, s1 and s2, write code to 
 check if s2 is a rotation of s1 using only one call to isSubstring 
 (e.g., "waterbottle" is a rotation of "erbottlewat").
*/

 #include <iostream>
#include <stdio.h>
#include <string>
#include <sstream>
#include <string.h>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <functional>
#include <cmath>
using namespace std;

bool isRotation(string& s1,string& s2)
{
        if(s1.length() !=  s2.length())
                return false;
        string s3 = s1 + s1;
        //return isSubstring(s2,s3);
        return s3.find(s2) != std::string::npos;
}

int main(int argc, char const *argv[])
{
        string s1 ="abcdef";
        string s2 = "defabc";
        cout<<isRotation(s1,s2)<<endl;
        return 0;
}
/*
CCP 1.8
Assume you have a method isSubstring which checks if one word is
 a substring of another. Given two strings, s1 and s2, write code to 
 check if s2 is a rotation of s1 using only one call to isSubstring 
 (e.g., "waterbottle" is a rotation of "erbottlewat").
*/

 #include <iostream>
#include <stdio.h>
#include <string>
#include <sstream>
#include <string.h>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <functional>
#include <cmath>
using namespace std;

bool isRotation(string& s1,string& s2)
{
        if(s1.length() !=  s2.length())
                return false;
        string s3 = s1 + s1;
        //return isSubstring(s2,s3);
        return s3.find(s2) != std::string::npos;
}

int main(int argc, char const *argv[])
{
        string s1 ="abcdef";
        string s2 = "defabc";
        cout<<isRotation(s1,s2)<<endl;
        return 0;
}
